package com.base.cn.platform.os.service.course.cou.play;

import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.course.CourseBaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 课程播放接口
 *
 * @author s.li
 * @create 2018-05-31-15:11
 */
@FeignClient(name = CourseBaseService.appName,configuration = FeignAuthConfig.class)
public interface PlayCourseService extends CourseBaseService {

    /**
     * 获取课程播放页面数据
     * @param userId 用户ID
     * @param packageId 餐ID，普通课程传0
     * @param courseId 被播放的课程ID，如果是套餐则传套餐下的课程ID，如果是普通课程则传课程的ID
     * @return CourseBuyRecord
     */
    @RequestMapping(contextPath + "/getPlayCourseBuyRecord")
    Map<String,Object> getPlayCourseBuyRecord(@RequestParam("userId") BigDecimal userId,
                                              @RequestParam(value = "packageId", required = false, defaultValue = "0") BigDecimal packageId,
                                              @RequestParam(value = "courseId", required = false, defaultValue = "0") BigDecimal courseId);

    /**
     * 验证节点的播放
     * @param buyCourseId 课程或套餐ID（购买的课程ID）
     * @param courseId 课程ID
     * @param prevCatalogId 前一个目录节点ID
     * @param catalogId 目录节点ID
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/checkCourseCatalogPlay")
    Map<String,Object> checkCourseCatalogPlay(@RequestParam("buyCourseId") BigDecimal buyCourseId,
                                              @RequestParam("courseId") BigDecimal courseId,
                                              @RequestParam("prevCatalogId") BigDecimal prevCatalogId,
                                              @RequestParam("catalogId") BigDecimal catalogId,
                                              @RequestParam("userId") BigDecimal userId);

    /**
     * 获取播放数据
     * @param sign 签名
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/loadPlayData")
    Map<String,Object> loadPlayData(@RequestParam("sign") String sign,@RequestParam("source") String source, @RequestParam(value = "nickname", required = false) String nickname,
                                    @RequestParam(value = "userAvatar", required = false) String userAvatar, @RequestParam(value = "userId",required = false) BigDecimal userId);

    /**
     * 验证随堂练习数据
     * @param courseId 购买课程的ID
     * @param catalogId 目录ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/checkExercises")
    Map<String,Object> checkExercises(@RequestParam("userId") BigDecimal userId,
                                      @RequestParam("courseId") BigDecimal courseId,
                                      @RequestParam("catalogId") BigDecimal catalogId);

    /**
     * 查询用户播放最新节点
     * @param userId 用户ID
     * @param buyCourseId 购买的课程ID
     * @param courseId 播放的课程ID
     * @return  CoursePlayRecord
     */
    @RequestMapping(contextPath+"/findUserNewPlayRecord")
    Map<String,Object> findUserNewPlayRecord(@RequestParam("userId") BigDecimal userId,
                                             @RequestParam(value = "buyCourseId", required = false) BigDecimal buyCourseId,
                                             @RequestParam(value = "courseId", required = false) BigDecimal courseId);
}
